using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.skill
{
[System.Serializable]
public  class SkillRealm :   cfg.EditorReadWriter 
 {

    public string name  = "";
     public string icon  = "";
     public int needLv ;
     public cfg.condition.Item activeItem  = new cfg.condition.Item();
     public cfg.condition.Currency activeCurrency  = new cfg.condition.Currency();
     public cfg.condition.Items lockedCosts  = new cfg.condition.Items();
     public System.Collections.Generic.List<cfg.skill.SkillRefreshCost> refreshCosts  = new System.Collections.Generic.List<cfg.skill.SkillRefreshCost>();
     public System.Collections.Generic.List<cfg.fight.AttributeType> recommendAttrs  = new System.Collections.Generic.List<cfg.fight.AttributeType>();
     public System.Collections.Generic.List<cfg.skill.ColorRandomAttr> initAttrs  = new System.Collections.Generic.List<cfg.skill.ColorRandomAttr>();
     public System.Collections.Generic.List<cfg.skill.ColorRandomAttr> randomAttrs  = new System.Collections.Generic.List<cfg.skill.ColorRandomAttr>();
     


    public const int TYPE_ID = 387573477;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(10);
        os.WriteSize(Tag.STRING | (1 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(icon);  
         os.WriteSize(Tag.INT | (3 << Tag.TAG_SHIFT));  os.WriteInt(needLv);  
         os.WriteSize(Tag.BEAN | (4 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_Item(activeItem,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.BEAN | (5 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_Currency(activeCurrency,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.BEAN | (6 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_Items(lockedCosts,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (7 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_skill_SkillRefreshCost(refreshCosts,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (8 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_fight_AttributeType(recommendAttrs,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (9 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_skill_ColorRandomAttr(initAttrs,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (10 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_skill_ColorRandomAttr(randomAttrs,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.STRING | (1 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   icon = os.ReadString(); break;  
             case (Tag.INT | (3 << Tag.TAG_SHIFT)):   needLv = os.ReadInt(); break;  
             case (Tag.BEAN | (4 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); activeItem = cfg.Extensions.unmarshal_compatible_cfg_condition_Item(os); os = _oldOs; break; }   
             case (Tag.BEAN | (5 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); activeCurrency = cfg.Extensions.unmarshal_compatible_cfg_condition_Currency(os); os = _oldOs; break; }   
             case (Tag.BEAN | (6 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); lockedCosts = cfg.Extensions.unmarshal_compatible_cfg_condition_Items(os); os = _oldOs; break; }   
             case (Tag.LIST | (7 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); refreshCosts = cfg.Extensions.unmarshal_compatible_list_cfg_skill_SkillRefreshCost(os); os = _oldOs; break; }   
             case (Tag.LIST | (8 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); recommendAttrs = cfg.Extensions.unmarshal_compatible_list_cfg_fight_AttributeType(os); os = _oldOs; break; }   
             case (Tag.LIST | (9 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); initAttrs = cfg.Extensions.unmarshal_compatible_list_cfg_skill_ColorRandomAttr(os); os = _oldOs; break; }   
             case (Tag.LIST | (10 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); randomAttrs = cfg.Extensions.unmarshal_compatible_list_cfg_skill_ColorRandomAttr(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "SkillRealm");
        ele.WriteStartElement("name"); ele.WriteAttributeString("id", "1"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("icon"); ele.WriteAttributeString("id", "2"); ele.WriteString2(icon); ele.WriteEndElement();
         ele.WriteStartElement("needLv"); ele.WriteAttributeString("id", "3"); ele.WriteInt(needLv); ele.WriteEndElement();
         ele.WriteStartElement("activeItem"); ele.WriteAttributeString("id", "4"); cfg.Extensions.xml_marshal_cfg_condition_Item(activeItem,ele); ele.WriteEndElement();
         ele.WriteStartElement("activeCurrency"); ele.WriteAttributeString("id", "5"); cfg.Extensions.xml_marshal_cfg_condition_Currency(activeCurrency,ele); ele.WriteEndElement();
         ele.WriteStartElement("lockedCosts"); ele.WriteAttributeString("id", "6"); cfg.Extensions.xml_marshal_cfg_condition_Items(lockedCosts,ele); ele.WriteEndElement();
         ele.WriteStartElement("refreshCosts"); ele.WriteAttributeString("id", "7"); cfg.Extensions.xml_marshal_list_cfg_skill_SkillRefreshCost(refreshCosts,ele); ele.WriteEndElement();
         ele.WriteStartElement("recommendAttrs"); ele.WriteAttributeString("id", "8"); cfg.Extensions.xml_marshal_list_cfg_fight_AttributeType(recommendAttrs,ele); ele.WriteEndElement();
         ele.WriteStartElement("initAttrs"); ele.WriteAttributeString("id", "9"); cfg.Extensions.xml_marshal_list_cfg_skill_ColorRandomAttr(initAttrs,ele); ele.WriteEndElement();
         ele.WriteStartElement("randomAttrs"); ele.WriteAttributeString("id", "10"); cfg.Extensions.xml_marshal_list_cfg_skill_ColorRandomAttr(randomAttrs,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  name = ele.ReadString2(); break; 
                 case 2:  icon = ele.ReadString2(); break; 
                 case 3:  needLv = ele.ReadInt(); break; 
                 case 4:  activeItem = cfg.Extensions.xml_unmarshal_cfg_condition_Item(ele); break; 
                 case 5:  activeCurrency = cfg.Extensions.xml_unmarshal_cfg_condition_Currency(ele); break; 
                 case 6:  lockedCosts = cfg.Extensions.xml_unmarshal_cfg_condition_Items(ele); break; 
                 case 7:  refreshCosts = cfg.Extensions.xml_unmarshal_list_cfg_skill_SkillRefreshCost(ele); break; 
                 case 8:  recommendAttrs = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttributeType(ele); break; 
                 case 9:  initAttrs = cfg.Extensions.xml_unmarshal_list_cfg_skill_ColorRandomAttr(ele); break; 
                 case 10:  randomAttrs = cfg.Extensions.xml_unmarshal_list_cfg_skill_ColorRandomAttr(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "name":  name = ele.ReadString2(); break; 
                 case "icon":  icon = ele.ReadString2(); break; 
                 case "need_lv":  needLv = ele.ReadInt(); break; 
                 case "active_item":  activeItem = cfg.Extensions.xml_unmarshal_cfg_condition_Item(ele); break; 
                 case "active_currency":  activeCurrency = cfg.Extensions.xml_unmarshal_cfg_condition_Currency(ele); break; 
                 case "locked_costs":  lockedCosts = cfg.Extensions.xml_unmarshal_cfg_condition_Items(ele); break; 
                 case "refresh_costs":  refreshCosts = cfg.Extensions.xml_unmarshal_list_cfg_skill_SkillRefreshCost(ele); break; 
                 case "recommend_attrs":  recommendAttrs = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttributeType(ele); break; 
                 case "init_attrs":  initAttrs = cfg.Extensions.xml_unmarshal_list_cfg_skill_ColorRandomAttr(ele); break; 
                 case "random_attrs":  randomAttrs = cfg.Extensions.xml_unmarshal_list_cfg_skill_ColorRandomAttr(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
